/*
 * Copyright (c) 2018-2999 九五云信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.platform.controller;
import com.yami.shop.bean.dto.FlowAnalysisDto;
import com.yami.shop.bean.dto.SystemDto;
import com.yami.shop.bean.param.FlowAnalysisParam;
import com.yami.shop.service.FlowUserAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author lgh on 2018/11/26.
 */
@RestController
@RequestMapping("/platform/flowAnalysis")
public class FlowAnalysisController {

    @Autowired
    private FlowUserAnalysisService flowUserAnalysisService;

    /**
     * 流量总览
     */
    @GetMapping("/getAnalysisData")
    public ResponseEntity<FlowAnalysisDto> page(FlowAnalysisParam flowAnalysisParam) {
        //获取开始和结束时间
        flowAnalysisParam.setTime(1);
        FlowAnalysisDto flowAnalysisDto = flowUserAnalysisService. getFlowAnalysisData(flowAnalysisParam);
        return ResponseEntity.ok(flowAnalysisDto);
    }

    /**
     * 流量趋势
     */
    @GetMapping("/flowTrend")
    public ResponseEntity<List<FlowAnalysisDto>> flowTrend(FlowAnalysisParam flowAnalysisParam) {
        // 获取开始和结束时间
        flowAnalysisParam.setTime(2);
        List<FlowAnalysisDto> flowAnalysisDtoList = flowUserAnalysisService.flowTrend(flowAnalysisParam);
        return ResponseEntity.ok(flowAnalysisDtoList);
    }

    /**
     * 流量来源构成
     */
    @GetMapping("/flowSour")
    public ResponseEntity<List<FlowAnalysisDto>> flowSour(FlowAnalysisParam flowAnalysisParam) {
        flowAnalysisParam.setTime(1);
        List<FlowAnalysisDto> flowAnalysisDtoList = flowUserAnalysisService.flowSour(flowAnalysisParam);
        return ResponseEntity.ok(flowAnalysisDtoList);
    }

    /**
     * 系统访客数量
     */
    @GetMapping("/systemTypeNums")
    public ResponseEntity<SystemDto> systemTypeNums(FlowAnalysisParam flowAnalysisParam) {
        flowAnalysisParam.setTime(1);
        SystemDto systemDto = flowUserAnalysisService.systemTypeNums(flowAnalysisParam);
        return ResponseEntity.ok(systemDto);
    }
}
